import { RouteRecordRaw } from 'vue-router';

/**
 * 建议：路由 path 路径与文件夹名称相同，找文件可浏览器地址找，方便定位文件位置
 *
 * 路由meta对象参数说明
 * meta: {
 *      title:          菜单栏及 tagsView 栏、菜单搜索名称（国际化）
 *      isLink：        是否超链接菜单，开启外链条件，`1、isLink: 链接地址不为空 2、isIframe:false`
 *      isHide：        是否隐藏此路由
 *      isKeepAlive：   是否缓存组件状态
 *      isAffix：       是否固定在 tagsView 栏上
 *      isIframe：      是否内嵌窗口，开启条件，`1、isIframe:true 2、isLink：链接地址不为空`
 *      roles：         当前路由权限标识，取角色管理。控制路由显示、隐藏。超级管理员：admin 普通角色：common
 *      icon：          菜单、tagsView 图标，阿里：加 `iconfont xxx`，fontawesome：加 `fa xxx`
 * }
 */

// 扩展 RouteMeta 接口
declare module 'vue-router' {
	interface RouteMeta {
		title?: string;
		isLink?: string;
		isHide?: boolean;
		isKeepAlive?: boolean;
		isAffix?: boolean;
		isIframe?: boolean;
		roles?: string[];
		icon?: string;
	}
}

/**
 * 定义动态路由
 * 前端添加路由，请在顶级节点的 `children 数组` 里添加
 * @description 未开启 isRequestRoutes 为 true 时使用（前端控制路由），开启时第一个顶级 children 的路由将被替换成接口请求回来的路由数据
 * @description 各字段请查看 `/@/views/system/menu/component/addMenu.vue 下的 ruleForm`
 * @returns 返回路由菜单数据
 */
export const dynamicRoutes: Array<RouteRecordRaw> = [
	{
		path: '/',
		name: '/',
		component: () => import('/@/layout/index.vue'),
		redirect: '/home',
		meta: {
			isKeepAlive: true,
		},
		children: [
			//首页
			{
				path: '/home',
				name: 'home',
				component: () => import('/@/views/home/index.vue'),
				meta: {
					isAffix: true
				},
			},
			//创业/就业
			{
				path: '/article',
				name: 'article',
				component: () => import('/@/views/article/index.vue'),
				meta: {
				},
			},
			//志愿者招募
			{
				path: '/volunteer',
				name: 'volunteer',
				component: () => import('/@/views/error/404.vue'),
				meta: {
				},
			},
			//乡俗民情
			{
				path: '/public_welfare',
				name: 'public_welfare',
				component: () => import('/@/views/error/404.vue'),
				meta: {
				},
			},
			//政策咨询
			{
				path: '/policy',
				name: 'policy',
				component: () => import('/@/views/error/404.vue'),
				meta: {
				},
			},
			//金融服务
			{
				path: '/finance',
				name: 'finance',
				component: () => import('/@/views/error/404.vue'),
				meta: {
				}
			},
			//教育培训
			{
				path: '/educate',
				name: 'educate',
				component: () => import('/@/views/error/404.vue'),
				meta: {
				},
			},
			// 健康医疗
			{
				path: '/treat',
				name: 'treat',
				component: () => import('/@/views/error/404.vue'),
				meta: {
				},
			},
			// 报名记录
			{
				path: '/sign_record',
				name: 'sign_record',
				component: () => import('/@/views/error/404.vue'),
				meta: {
				},
			},
			//公共配置
			{
				path: '/public',
				name: 'publicIndex',
				component: () => import('/@/views/error/404.vue'),
				meta: {
				},
				children: [
					{
						path: '/public/menu',
						name: 'publicType1',
						component: () => import('/@/views/public/menu/index.vue'),
						meta: {

						}
					},
					{
						path: '/public/role',
						name: 'publicType2',
						component: () => import('/@/views/public/role/index.vue'),
						meta: {

						}
					},
					{
						path: '/public/swiper',
						name: 'publicType3',
						component: () => import('/@/views/public/swiper/index.vue'),
						meta: {

						}
					},
					{
						path: '/public/notice',
						name: 'publicType',
						component: () => import('/@/views/public/notice/index.vue'),
						meta: {
						}
					}
				]
			},
			//积分商城
			{
				path: '/jifen',
				name: 'jifen',
				component: () => import('/@/views/error/404.vue'),
				redirect: '/jifen/pointProclass',
				meta: {

				},
				children: [
					{
						path: '/jifen/pointProclass',
						name: 'pointProclass',
						component: () => import('/@/views/score/score_goods_type/index.vue'),
						meta: {

						}
					},
					{
						path: '/jifen/pointPro',
						name: 'pointPro',
						component: () => import('/@/views/score/score_goods/index.vue'),
						meta: {
						}
					},
					{
						path: '/jifen/pointBanner',
						name: 'pointBanner',
						component: () => import('/@/views/score/score_swiper/index.vue'),
						meta: {
						}
					},
					{
						path: '/jifen/score',
						name: 'score',
						component: () => import('/@/views/score/score_history/index.vue'),
						meta: {
						}
					}
				]
			},
			//美食管理
			{
				path: '/food',
				name: 'food',
				component: () => import('/@/views/error/404.vue'),
				redirect: '/food/delicacy',
				meta: {
				},
				children: [
					// 店铺管理
					{
						path: '/food/delicacy',
						name: 'delicacy',
						component: () => import('/@/views/food/food_shop/index.vue'),
						meta: {
						}
					},
					// 店铺分类
					{
						path: '/food/delicacyClass',
						name: 'delicacyClass',
						component: () => import('/@/views/food/food_shoptype/index.vue'),
						meta: {
						}
					},
					{
						path: '/food/delicacyProduct',
						name: 'delicacyProduct',
						component: () => import('/@/views/food/food_product/index.vue'),
						meta: {
						}
					},
					// 订单
					{
						path: '/food/delicacyOrder',
						name: 'delicacyOrder',
						component: () => import('/@/views/food/food_order/index.vue'),
						meta: {
						}
					},
					// 商品分类
					{
						path: '/food/delicacyprotype',
						name: 'delicacyprotype',
						component: () => import('/@/views/food/food_producttype/index.vue'),
						meta: {
						}
					},
					// 会员列表
					{
						path: '/food/delicacy_member',
						name: 'delicacy_member',
						component: () => import('/@/views/error/404.vue'),
						meta: {
						}
					}
				]
			},
			//游玩管理
			{
				path: '/scenic',
				name: 'scenic',
				component: () => import('/@/views/error/404.vue'),
				redirect: '/scenic/scenic_type',
				meta: {
				},
				children: [
					{
						path: '/scenic/scenic_type',
						name: 'scenic_type',
						component: () => import('/@/views/scenic/scenic_class/index.vue'),
						meta: {
						}
					},
					{
						path: '/scenic/scenic_goods',
						name: 'scenic_goods',
						component: () => import('/@/views/scenic/scenic_goods/index.vue'),
						meta: {
						}
					},
					{
						path: '/scenic/scenic_ticket',
						name: 'scenic_ticket',
						component: () => import('/@/views/scenic/scenic_ticket/index.vue'),
						meta: {
						}
					},
					{
						path: '/scenic/scenic_order',
						name: 'scenic_order',
						component: () => import('/@/views/scenic/scenic_order/index.vue'),
						meta: {
						}
					},
					{
						path: '/scenic/scenic_member',
						name: 'scenic_member',
						component: () => import('/@/views/error/404.vue'),
						meta: {
						}
					}
				]
			},
			//娱乐管理
			{
				path: '/lark',
				name: 'lark',
				component: () => import('/@/views/error/404.vue'),
				redirect: '/lark/lark_type_group',
				meta: {
				},
				children: [
					{
						path: '/lark/lark_type_group',
						name: 'lark_type_group',
						component: () => import('/@/views/lark/lark_type_group/index.vue'),
						meta: {
						}
					},
					{
						path: '/lark/lark_type',
						name: 'lark_type',
						component: () => import('/@/views/lark/lark_type/index.vue'),
						meta: {
						}
					},
					{
						path: '/lark/lark_shop',
						name: 'lark_shop',
						component: () => import('/@/views/lark/lark_shop/index.vue'),
						meta: {
						}
					},
					{
						path: '/lark/lark_goods',
						name: 'lark_goods',
						component: () => import('/@/views/lark/lark_goods/index.vue'),
						meta: {
						}
					},
					{
						path: '/lark/lark_list',
						name: 'lark_list',
						component: () => import('/@/views/lark/lark_order/index.vue'),
						meta: {
						}
					},
					{
						path: '/lark/lark_member',
						name: 'lark_member',
						component: () => import('/@/views/error/404.vue'),
						meta: {
						}
					}
				]
			},
			//酒店管理
			{
				path: '/room',
				name: 'room',
				component: () => import('/@/views/error/404.vue'),
				redirect: '/room/room_room',
				meta: {
				},
				children: [
					{
						path: '/room/room_order',
						name: 'room_order',
						component: () => import('/@/views/error/404.vue'),
						meta: {
						}
					},
					{
						path: '/room/room_room',
						name: 'room_room',
						component: () => import('/@/views/error/404.vue'),
						meta: {
						}
					},
					{
						path: '/room/room_type',
						name: 'room_type',
						component: () => import('/@/views/error/404.vue'),
						meta: {
						}
					},
					{
						path: '/room/room_shop',
						name: 'room_shop',
						component: () => import('/@/views/error/404.vue'),
						meta: {
						}
					},
					{
						path: '/room/room_member',
						name: 'room_member',
						component: () => import('/@/views/error/404.vue'),
						meta: {
						}
					},
				]
			},
			{
				path: '/message',
				name: 'message',
				component: () => import('/@/views/error/404.vue'),
				meta: {
				}
			},
			{
				path: '/email',
				name: 'email',
				component: () => import('/@/views/error/404.vue'),
				redirect: '/email/email_list',
				meta: {
				},
				children: [
					{
						path: '/email/email_list',
						name: 'email_list',
						component: () => import('/@/views/error/404.vue'),
						meta: {
						}
					},
					{
						path: '/email/email_type',
						name: 'email_type',
						component: () => import('/@/views/error/404.vue'),
						meta: {

						}
					},
				]
			},
			{
				path: '/companylist',
				name: 'companylist',
				component: () => import('/@/views/error/404.vue'),
				meta: {
				}
			},
			{
				path: '/after',
				name: 'after',
				component: () => import('/@/views/error/404.vue'),
				meta: {
				}
			},
			// {
			// 	path: '/redirect',
			// 	component: () => import(),
			// }
		],
	},
];

/**
 * 定义404、401界面
 * @link 参考：https://next.router.vuejs.org/zh/guide/essentials/history-mode.html#netlify
 */
export const notFoundAndNoPower = [
	{
		path: '/:path(.*)*',
		name: 'notFound',
		component: () => import('/@/views/error/404.vue'),
		meta: {
			title: 'message.staticRoutes.notFound',
			isHide: true,
		},
	},
	{
		path: '/401',
		name: 'noPower',
		component: () => import('/@/views/error/401.vue'),
		meta: {
			title: 'message.staticRoutes.noPower',
			isHide: true,
		},
	},
];

/**
 * 定义静态路由（默认路由）
 * 此路由不要动，前端添加路由的话，请在 `dynamicRoutes 数组` 中添加
 * @description 前端控制直接改 dynamicRoutes 中的路由，后端控制不需要修改，请求接口路由数据时，会覆盖 dynamicRoutes 第一个顶级 children 的内容（全屏，不包含 layout 中的路由出口）
 * @returns 返回路由菜单数据
 */
export const staticRoutes: Array<RouteRecordRaw> = [
	{
		path: '/login',
		name: 'login',
		component: () => import('/@/views/login/index.vue'),
		meta: {
			title: '登录',
		},
	},
	/**
	 * 提示：写在这里的为全屏界面，不建议写在这里
	 * 请写在 `dynamicRoutes` 路由数组中
	 */
	{
		path: '/visualizingDemo1',
		name: 'visualizingDemo1',
		component: () => import('/@/views/visualizing/demo1.vue'),
		meta: {
			title: 'message.router.visualizingLinkDemo1',
		},
	},
	{
		path: '/visualizingDemo2',
		name: 'visualizingDemo2',
		component: () => import('/@/views/visualizing/demo2.vue'),
		meta: {
			title: 'message.router.visualizingLinkDemo2',
		},
	},
];
